package com.news.service;

import java.util.ArrayList;
import java.util.List;

import com.news.dao.NewsPageDao;
import com.news.entity.News;
import com.news.entity.Page;

public class NewsPageService {

	public List<Page> getPages(){
		NewsPageDao pageDao =new NewsPageDao();
		int total =pageDao.getTotal();
		int pageSize =pageDao.pageSize;
		int pageCount=(total%pageSize==0?total/pageSize:total/pageSize+1);
		List<Page> pages =new ArrayList<Page>();
		for(int i=1;i<=pageCount;i++){
			Page page =new Page();
			page.setNumber(i);
			page.setText("第"+i+"页");
			pages.add(page);
		}
		return pages;
	}
	
	public List<News> getNewsByCurrentPage(int current) {
		NewsPageDao newsPageDao=new NewsPageDao();
		return newsPageDao.getNewsByCurrentPage(current);
	}
}
